#ifndef __MY_ZLOG_H__
#define __MY_ZLOG_H__

#include "zlog.h"
#include "stdbool.h"
extern bool myzlog_init(void);

/*==================================自定义==========*/

extern zlog_category_t *zcat;
// zlog_category_t *zcat_data;
extern bool zlog_inited;

//====================== 打印 ====================== //
#define INFO(fmt, ...)                           \
    do                                           \
    {                                            \
        if (zlog_inited)                         \
            zlog_info(zcat, fmt, ##__VA_ARGS__); \
    } while (0)
#define ERROR(fmt, ...)                           \
    do                                            \
    {                                             \
        if (zlog_inited)                          \
            zlog_error(zcat, fmt, ##__VA_ARGS__); \
    } while (0)

#define WARN(fmt, ...)                           \
    do                                           \
    {                                            \
        if (zlog_inited)                         \
            zlog_warn(zcat, fmt, ##__VA_ARGS__); \
    } while (0)
#define INFO_BYTES(a__header, a__data, a__size, ...)                         \
    {                                                                        \
        uint8_t *__data = (uint8_t *)(a__data);                              \
        int __size = (int)(a__size);                                         \
        char __buffer[4096];                                                 \
        memset(__buffer, 0, sizeof(__buffer));                               \
        sprintf(__buffer, "[" a__header "]", ##__VA_ARGS__);                 \
        sprintf(__buffer + strlen(__buffer), ":len=%d ,", __size);           \
        int __iii = 0;                                                       \
        int __offset = strlen(__buffer);                                     \
        while (__iii < __size && __iii < (sizeof(__buffer) / 2))             \
        {                                                                    \
            sprintf(__buffer + __offset + __iii * 2, "%02X", __data[__iii]); \
            __iii++;                                                         \
        }                                                                    \
        zlog_info(zcat, "%s", __buffer);                                     \
    }

#endif // !__MY_ZLOG_H__
